package com.samshow.base.program;

import onbon.bx05.area.BxArea;
import onbon.bx05.area.TextCaptionBxArea;
import onbon.bx05.area.page.BxPage;
import onbon.bx05.file.BxFile;
import onbon.bx05.file.ProgramBxFile;

import java.util.List;

/**
 * Created by niwb on 2017/2/22.
 */
public class TextProgram implements Program {
    private ProgramFactory programFactory;

    public TextProgram(ProgramFactory programFactory) {
        this.programFactory = programFactory;
    }

    @Override
    public BxFile prepareProgram() {
        BxFile bxFile = programFactory.createBxFile();
        ProgramBxFile programBxFile = (ProgramBxFile) bxFile;
        BxArea bxArea = programFactory.createBxArea();
        TextCaptionBxArea textCaptionBxArea = (TextCaptionBxArea) bxArea;
        List<BxPage> bxPages = programFactory.createBxPage();
        for (BxPage bxPage : bxPages) {
            textCaptionBxArea.addPage(bxPage);
        }
        programBxFile.addArea(textCaptionBxArea);
        return programBxFile;
    }
}
